package com.qf.xiaomi.web.servlet;

import com.qf.xiaomi.pojo.TbAddress;
import com.qf.xiaomi.pojo.TbUser;
import com.qf.xiaomi.service.AddressService;
import com.qf.xiaomi.service.impl.AddressServiceImpl;
import com.qf.xiaomi.utils.StringConstans;
import com.qf.xiaomi.web.base.BaseServlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/userservlet")
public class UserAdressServlet extends BaseServlet {
    AddressService service = new AddressServiceImpl();
    public String getAddress(HttpServletRequest req, HttpServletResponse resp){
        TbUser user = (TbUser) req.getSession().getAttribute("user");
        long uid = user.getId();

        List<TbAddress> list=new ArrayList<>();
        list=service.selectAddress(uid);

        req.setAttribute("list",list);
        return StringConstans.FORWARD+"/self_info.jsp";
    }
}